package com.shanshi.activity;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import static com.shanshi.activity.R.id.sidebar_avater;

public class MyMessage extends MainActivity implements OnClickListener{

	private SharedPreferences sharedPreferences;
	private TextView tv;
	private ImageView Iv;
	private ImageView EditImgBt;
	private ImageView avater;

	private TextView mymessage_name;
	private TextView mymessage_sex;
	private TextView mymessage_birthday;
	private TextView mymessage_family;
	private TextView mymessage_tel;
	private TextView mymessage_address;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mymessage);
		avater = (ImageView) findViewById(R.id.mymessage_avater);
		sharedPreferences = MyMessage.this.getSharedPreferences("share", MODE_PRIVATE);
		//加载非会员头像
		if(sharedPreferences.getString("shanShiId","").equals("")){
			Glide.with(MyMessage.this).load(R.drawable.name).centerCrop().into(avater);
		}else{
			//加载会员头像
			Glide.with(MyMessage.this).load(R.drawable.name2).centerCrop().into(avater);
		}
		tv = (TextView) findViewById(R.id.title);
		tv.setText("我的");
		Iv = (ImageView) findViewById(R.id.fanhui);
		Iv.setOnClickListener(this);
		EditImgBt = (ImageView) findViewById(R.id.mymessage_edit);
		EditImgBt.setOnClickListener(this);
		mymessage_name = (TextView) findViewById(R.id.mymessage_name);
		mymessage_name.setText(sharedPreferences.getString("nickName",""));
		mymessage_sex = (TextView) findViewById(R.id.mymessage_sex);
		mymessage_sex.setText(sharedPreferences.getString("sex",""));
		mymessage_birthday = (TextView) findViewById(R.id.mymessage_birthday);
		mymessage_birthday.setText(sharedPreferences.getString("birthday",""));
		mymessage_family = (TextView) findViewById(R.id.mymessage_family);
		mymessage_family.setText(sharedPreferences.getString("family",""));
		mymessage_tel = (TextView) findViewById(R.id.mymessage_tel);
		mymessage_tel.setText(sharedPreferences.getString("phoneNum",""));
		mymessage_address = (TextView) findViewById(R.id.mymessage_address);
		mymessage_address.setText(sharedPreferences.getString("addrProv","")+sharedPreferences.getString("addrCity","")+sharedPreferences.getString("addrDis","")+sharedPreferences.getString("addrStree",""));

	}

	@Override
	public void onClick(View v) {
		
		switch (v.getId()){
		//返回上一页面
		case R.id.fanhui:
			finish();
			break;
		//跳转到编辑页面	
		case R.id.mymessage_edit:
			Intent intent = new Intent(MyMessage.this,CompletePersonalInfoActivity.class);
			intent.putExtra("lastActivity",2);
			startActivity(intent);
			break;
		}
		
		
		
	}
}
